from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import ExamRoom

@receiver(post_save, sender=ExamRoom)
def handle_exam_room_save(sender, instance, created, **kwargs):
    """处理考场保存信号"""
    # 使用 Celery 任务处理考场状态变更
    if created or instance.status == 'preparing':
        # 新创建的考场或状态为preparing的考场，使用 Celery 设置定时任务
        # Celery Beat 会自动处理定时任务
        pass
    elif instance.status in ['finished', 'cancelled']:
        # 已结束或已取消的考场
        pass